//
// field_defns.cpp
// libprotea
// Tools Library for the Protea Project / Data type definitions for Fields
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please send correspondence to:
// 
// theproteaproject@gmail.com
//

#include "../defines.h"
#include "field_defns.h"

const tdata_type_defnition data_type_defns[ MAX_TYPE + 1 ] = {
	// 0 = BIG_STRING
	{
		TYPE_STRING, "Big String",
		0, 0,
		0, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110000000111111111111111110111001111111110001100000"		// 0
	},

	// 1 = STRING
	{
		TYPE_STRING, "String",
		1, 0,
		1, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110000000111111111111111110111001111111110001100010"		// 1
	},

	// 2 = ALPHA_STRING
	{ 
		TYPE_STRING, "Alpha String",
		2, 0,
		2, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"111000000000000000000000000000001111111110000100000"		// 2
	},

	// 3 = DISPLAY_NUM
	{
		TYPE_STRING | TYPE_NUMERIC, "Display Numeric",
		-1, 0,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111110000000100"		//	3
	},

	// 4 = DEC_FLOAT
	{ 
		TYPE_NUMERIC, "Float",
		4, 4,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000100"		//	4
	},

	// 5 = DEC_DOUBLE
	{
		TYPE_NUMERIC, "Double",
		5, 8,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000100"		//	5
	},

	// 6 = S_INTEGER
	{
		TYPE_NUMERIC, "Single Integer",
		6, 2,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000100"		//	6
	},

	// 7 = D_INTEGER
	{
		TYPE_NUMERIC, "Double Integer",
		7, 4,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000100"		//	7
	},

	// 8 = DATE_JULIAN
	{
		TYPE_DATE, "Julian Date",
		8, 8,
		-1, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000000001111111111110000000000001111111111100000000"		//	8
	},

	// 9 = DATE_MDY
	{
		TYPE_DATE, "MDY Date",
		42, 0,
		9, 6,
		0, 6, 6,
		{ {3, 6, 0}, 0, 0, 0, 0, false, false },		// MMDDYY
		"110000001111111111110000000000001111111111100000000"		//	9
	},

	// 10 = DATE_MDY_DISPLAY
	{
		TYPE_DATE, "MDY Display Date",
		42, 0,
		10, 8,
		0, 8, 8,
		{ {3, 6, 0}, 1, 1, 0, 0, false, false },		// MM/DD/YY
		"110000001111111111110000000000001111111111100000000"		//	10
	},

	// 11 = DATE_YMD
	{
		TYPE_DATE, "YMD Date",
		42, 0,
		11, 6,
		0, 6, 6,
		{ {2, 3, 6}, 0, 0, 0, 0, false, false },		// YYMMDD
		"110000001111111111110000000000001111111111100000000"		//	11
	},

	// 12 = DATE_YMD_DISPLAY
	{
		TYPE_DATE, "YMD Display Date",
		42, 0,
		12, 8,
		0, 8, 8,
		{ {0, 3, 6}, 1, 1, 0, 0, false, false },		// YY/MM/DD
		"110000001111111111110000000000001111111111100000000"		//	12
	},

	// 13 = DATE_DMY
	{
		TYPE_DATE, "DMY Date",
		42, 0,
		13, 6,
		0, 6, 6,
		{ {6, 3, 0}, 0, 0, 0, 0, false, false },		// DDMMYY
		"110000001111111111110000000000001111111111100000000"		//	13
	},

	// 14 = DATE_DMY_DISPLAY
	{
		TYPE_DATE, "DMY Display Date",
		42, 0,
		14, 8,
		0, 8, 8,
		{ {6, 3, 0}, 1, 1, 0, 0, false, false },	// DD/MM/YY
		"110000001111111111110000000000001111111111100000000"		//	14
	},

	// 15 = DATE_STR_DISPLAY
	{
		TYPE_DATE, "String Display Date",
		42, 0,
		15, 0,
		0, 254, 0,
		{ {4, 6, 1}, 0, 3, 1, 0, false, false },	// E.G. MAY 1, 1980
		"110000001111111111110000000000001111111111100000000"		//	15
	},

	// 16 = DATE_MD
	{
		TYPE_DATE | TYPE_SHORT_DATE, "MD Date",
		42, 0,
		16, 4,
		0, 4, 4,
		{ {3, 6, -1}, 0, 0, 0, 0, false, false },		// MMDD
		"110000000000000011110000000000001111111111100000000"		//	16
	},

	// 17 = DATE_MD_DISPLAY
	{
		TYPE_DATE | TYPE_SHORT_DATE, "MD Display Date",
		42, 0,
		17, 5,
		0, 5, 5,
		{ {3, 6, -1}, 1, 1, 0, 0, false, false },		// MM/DD
		"110000000000000011110000000000001111111111100000000"		//	17
	},

	// 18 = DATE_DM
	{
		TYPE_DATE | TYPE_SHORT_DATE, "DM Date",
		42, 0,
		18, 4,
		0, 4, 4,
		{ {6, 3, -1}, 0, 0, 0, 0, false, false },		// DDMM
		"110000000000000011110000000000001111111111100000000"		//	18
	},

	// 19 = DATE_DM_DISPLAY
	{
		TYPE_DATE | TYPE_SHORT_DATE, "DM Display Date",
		42, 0,
		19, 5,
		0, 5, 5,
		{ {6, 3, -1}, 1, 1, 0, 0, false, false },		// DD/MM
		"110000000000000011110000000000001111111111100000000"		//	19
	},

	// 20 = TIME_12HR
	{
		TYPE_TIME, "12HR Time",
		41, 0,
		20, 5,
		0, 5, 5,
		{ {-1, -1, -1}, 0, 0, 0, 3, false, false },		// HHMMA
		"110111110000000000001111110000001111111111000000100"		//	20
	},

	// 21 = TIME_12HR_DISPLAY
	{
		TYPE_TIME, "12HR Display Time",
		41, 0,
		21, 6,
		0, 6, 6,
		{ {-1, -1, -1}, 0, 0, 0, 3, true, false },		// HH:MMA
		"110111110000000000001111110000001111111111000000100"		//	21
	},

	// 22 = TIME_24HR
	{
		TYPE_TIME, "24HR Time",
		41, 0,
		22, 4,
		0, 4, 4,
		{ {-1, -1, -1}, 0, 0, 0, 3, false, true },		// HHMM
		"110111110000000000001111110000001111111111000000100"		//	22
	},

	// 23 = TIME_24HR_DISPLAY
	{
		TYPE_TIME, "24HR Display Time",
		41, 0,
		23, 5,
		0, 5, 5,
		{ {-1, -1, -1}, 0, 0, 0, 3, true, true },			// HH:MM
		"110111110000000000001111110000001111111111000000100"		//	23
	},

	// 24 = TIME_ER_12HR_DISP
	{
		TYPE_TIME, "EU 12HR Display Time",
		41, 0,
		24, 6,
		0, 6, 6,
		{ {-1, -1, -1}, 0, 0, 0, 3, true, false },		// HH.MMA
		"110111110000000000001111110000001111111111000000100"		//	24
	},

	// 25 = TIME_EU_24HR_DISP
	{
		TYPE_TIME, "EU 24HR Display Time",
		41, 0,
		25, 5,
		0, 5, 5,
		{ {-1, -1, -1}, 0, 0, 0, 3, true, true },		// HH.MM
		"110111110000000000001111110000001111111111000000100"		//	25
	},

	// 26 = DUR_HH_TIME
	{
		TYPE_DUR, "HH Time",
		26, 0,
		26, 0,
		2, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000000000001111001111111111000000100"		//	26
	},

	// 27 = DUR_HH_TIME_DISP
	{
		TYPE_DUR, "Dur HH Time Display",
		27, 0,
		27, 0,
		2, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110111110000000000000000001111001111111111000000100"		//	27
	},

	// 28 = DUR_HM_TIME
	{
		TYPE_DUR, "Dur HM Time",
		28, 0,
		28, 0,
		4, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110111110000000000000000001111001111111111000000100"		//	28
	},

	// 29 = DUR_HM_TIME_DISP
	{
		TYPE_DUR, "Dur HM Time Display",
		29, 0,
		29, 0,
		5, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110111110000000000000000001111001111111111000000100"		//	29
	},

	// 30 = NUM_LEFT_DISP
	{
		TYPE_STRING, "Numeric Left Display",
		5, 0,
		30, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110111110000000000000000001111001111111111000000000"		//	30
	},

	// 31 = DATE_CENTURY_YEAR
	{
		TYPE_DATE, "Century Year Date",
		42, 0,
		31, 4,
		0, 4, 4,
		{ {1, -1, -1}, 0, 0, 0, 0, false, false },	// CCYY
		"110111110000000000000000001111001111111111100000000"		//	31
	},

	// 32 = DATE_YEAR
	{
		TYPE_DATE, "Year Date",
		42, 0,
		32, 2,
		0, 2, 2,
		{ {0, -1, -1}, 0, 0, 0, 0, false, false },	// YY
		"110111110000000000000000001111001111111111100000100"		//	32
	},

	// 33 = DATE_CYMD
	{
		TYPE_DATE, "CYMD Date",
		42, 0,
		33, 8,
		0, 8, 8,
		{ {1, 3, 6}, 0, 0, 0, 0, false, false },		// CCYYMMDD
		"110000001111111111110000000000001111111111100000000"		//	33
	},

	// 34 = DATE_MDCY
	{
		TYPE_DATE, "MDCY Date",
		42, 0,
		34, 8,
		0, 8, 8,
		{ {3, 6, 1}, 0, 0, 0, 0, false, false },		// MMDDCCYY
		"110000001111111111110000000000001111111111100000000"		//	34
	},

	// 35 = DATE_DMCY
	{
		TYPE_DATE, "DMCY Date",
		42, 0,
		35, 8,
		0, 8, 8,
		{ {6, 3, 1}, 0, 0, 0, 0, false, false },		// DDMMCCYY
		"110000001111111111110000000000001111111111100000000"		//	35
	},

	// 36 = DATE_MDCY_DISPLAY
	{
		TYPE_DATE, "MDCY Display Date",
		42, 0,
		36, 10,
		0, 10, 10,
		{ {3, 6, 1}, 1, 1, 0, 0, false, false },		// MM/DD/CCYY
		"110000001111111111110000000000001111111111100000000"		//	36
	},

	// 37 = DATE_DMCY_DISPLAY
	{
		TYPE_DATE, "DMCY Display Date",
		42, 0,
		37, 10,
		0, 10, 10,
		{ {6, 3, 1}, 1, 1, 0, 0, false, false },		// DD/MM/CCYY
		"110000001111111111110000000000001111111111100000000"		//	37
	},

	// 38 = DATE_CYM
	{
		TYPE_DATE, "CYM Date",
		42, 0,
		38, 6,
		0, 6, 6,
		{ {1, 3, -1}, 0, 0, 0, 0, false, false },		// CCYYMM
		"110111110000000000000000001111001111111111100000100"		//	38
	},

	// 39 = DATE_YMD_USER
	{
		TYPE_DATE, "YMD User Date",
		42, 0,
		39, 6,
		0, 6, 6,
		{ {0, 3, 6}, 0, 0, 0, 0, false, false },		// YMD_USER - Not A0
		"110111110000000000000000001111001111111111100000100"		//	39
	},

	// 40 = DATE_TIMESTAMP
	{
		TYPE_DATE | TYPE_TIME, "Timestamp",
		40, 19,
//*		-1, 0,
		40, 19,
		0, 19, 19,
		{ {1, 3, 6}, 1, 1, 0, 7, true, true },		// Timestamp
		"110111110000000000000000001111001111111111100000100"		//	40
	},

	// 41 = TIME_24HR_DB
	{
		TYPE_TIME, "24HR DB Time",
		41, 8,
//*		-1, 0,
		41, 8,
		0, 8, 8,
		{ {-1, -1, -1}, 0, 0, 0, 7, true, true },		// Time format
		"110111110000000000000111001111001111111111000000100"		//	41
	},

	// 42 = DATE_DB
	{
		TYPE_DATE, "DB Date",
		42, 10,
//*		-1, 0,
		42, 10,
		0, 10, 10,
		{ {1, 3, 6}, 2, 2, 0, 0, false, false },		// Date_DB
		"110000001111111111110000000000001111111111100000000"		//	42
	},

	// 43 = DECIMAL_64
	{
		TYPE_NUMERIC, "Decimal",
		43, 0,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110111110000000000000000001111001111111111010000000"		//	43
	},

	// 44 = LITERAL_VAL
	{
		TYPE_NUMERIC, "Literal value",
		44, 4,
		49, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110000000000000000000000000000000000000000001000010"		// 44
	},

	// 45 = VAR_STRING
	{
		TYPE_STRING, "Variable string",
		45, 0,
		45, 0,
		0, 32767, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110000000000000000000000000000000000000000000100000"		// 45
	},

	// 46 = BLOB
	{
		TYPE_BLOB, "Blob",
		46, 0,
		46, 0,
		0, 32767, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000000000000000000000000000000000000000000000010000"		// 46
	},

	// 47 = DB_FUNCTION
	{
		TYPE_FUNCTION, "DB Function",
		47, 0,
		-1, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000000000000000000000000000000000000000000000001000"		//	47
	},

	// 48 = AUTONUMBER
	{
		TYPE_NUMERIC, "Autonumber",
		48, 4,
		3, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000100"		//	48
	},

	// 49 = LITERAL_STRING
	{
		TYPE_STRING, "Literal String",
		44, 0,
		49, 0,
		0, 254, 0,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"110000000000000000000000000000000000000000001000010"		// 49
	},

	// 50 = XCBOOL
	{
		TYPE_STRING, "Boolean",
		50, 1,
		50, 1,
		0, 1, 1,
		{ {-1, -1, -1}, 0, 0, 0, 0, false, false },
		"000111110000000000001111111111001111111111000000001"		// 50
	}
};


const tdata_type_defnition* GetDataTypeDefn( long defn ) {
	assert( defn >= MIN_TYPE );
	assert( defn <= MAX_TYPE );

	return &data_type_defns[ defn ];
};
